package vip.xiaonuo.supplier.modular.structure.org.provider;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import vip.xiaonuo.supplier.api.SupplierOrgApi;
import vip.xiaonuo.supplier.modular.structure.org.param.SupplierOrgSelectorOrgListParam;
import vip.xiaonuo.supplier.modular.structure.org.service.SupplierOrgService;

import java.util.List;

/**
 * 组织API接口提供者
 *
 * @author yubaoshan
 * @date 2024/11/1 18:27:51
 **/
@Service
public class SupplierOrgApiProvider implements SupplierOrgApi {

    @Resource
    private SupplierOrgService supplierOrgService;

    @Override
    public List<Tree<String>> orgTreeSelector() {
        return supplierOrgService.orgTreeSelector();
    }

    @SuppressWarnings("ALL")
    @Override
    public Page<JSONObject> orgListSelector(String parentId) {
        SupplierOrgSelectorOrgListParam supplierOrgSelectorOrgListParam = new SupplierOrgSelectorOrgListParam();
        supplierOrgSelectorOrgListParam.setParentId(parentId);
        return BeanUtil.toBean(supplierOrgService.orgListSelector(supplierOrgSelectorOrgListParam), Page.class);
    }
}
